package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormPartIn;
import com.glsc.ngateway.common.base.domainmapper.cmdb.FlowFormOuterPartInMapper;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.cmdb.domainDto.FlowFormPartInDto;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 配件新增/删除流程主表转换器
 * @author zhengyr
 */
public class FlowFormPartInConverter extends AbstractFlowFormDataConverter {
    public static FlowFormPartInDto do2Dto(FlowFormPartIn apply) {
        if (Objects.isNull(apply)) {
            return null;
        }
        FlowFormPartInDto applyDto = FlowFormOuterPartInMapper.INSTANCE.domain2dto(apply);
        applyDto.setAppendicesFileList(converter2FileList(apply.getAppendicesFileIdList()));
        return applyDto;
    }

    public static List<FlowFormPartInDto> do2Dto(List<FlowFormPartIn> applyList) {
        return CollectionUtils.isEmpty(applyList) ? java.util.Collections.emptyList() : applyList.stream().map(FlowFormPartInConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormPartIn dto2Do(FlowFormPartInDto applyDto) {
        if (Objects.isNull(applyDto)) {
            return null;
        }
        FlowFormPartIn apply = FlowFormOuterPartInMapper.INSTANCE.dto2domain(applyDto);
        apply.setAppendicesFileIdList(converter2FileIdList(applyDto.getAppendicesFileList()));
        return apply;
    }

    public static List<FlowFormPartIn> dto2Do(List<FlowFormPartInDto> applyDtoList) {
        return CollectionUtils.isEmpty(applyDtoList) ? java.util.Collections.emptyList() : applyDtoList.stream().map(FlowFormPartInConverter::dto2Do).collect(Collectors.toList());
    }

}
